home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / gfx / pbm / source1.lha / netpbm / pnm / pnmnoraw.c < prev    next >
C/C++ Source or Header  |  1993-10-04  |  1KB  |  50 lines

  1. /* pnmnoraw.c - force a portable anymap into ASCII format
  2. **
  3. ** Copyright (C) 1991 by Jef Poskanzer.
  4. **
  5. ** Permission to use, copy, modify, and distribute this software and its
  6. ** documentation for any purpose and without fee is hereby granted, provided
  7. ** that the above copyright notice appear in all copies and that both that
  8. ** copyright notice and this permission notice appear in supporting
  9. ** documentation.  This software is provided "as is" without express or
  10. ** implied warranty.
  11. */
  12.  
  13. #include "pnm.h"
  14.  
  15. int
  16. main( argc, argv )
  17.     int argc;
  18.     char* argv[];
  19.     {
  20.     FILE* ifp;
  21.     xelval maxval;
  22.     register xel* xelrow;
  23.     int rows, cols, format, row;
  24.  
  25.     pnm_init( &argc, argv );
  26.  
  27.     if ( argc > 2 )
  28.     pm_usage( "[pnmfile]" );
  29.  
  30.     if ( argc == 2 )
  31.     ifp = pm_openr( argv[1] );
  32.     else
  33.     ifp = stdin;
  34.  
  35.     pnm_readpnminit( ifp, &cols, &rows, &maxval, &format );
  36.     pnm_writepnminit( stdout, cols, rows, maxval, format, 1 );
  37.     xelrow = pnm_allocrow( cols );
  38.  
  39.     for ( row = 0; row < rows; ++row )
  40.     {
  41.     pnm_readpnmrow( ifp, xelrow, cols, maxval, format );
  42.     pnm_writepnmrow( stdout, xelrow, cols, maxval, format, 1 );
  43.     }
  44.  
  45.     pm_close( ifp );
  46.     pm_close( stdout );
  47.  
  48.     exit( 0 );
  49.     }
  50.